package thread;

class SingletonLazy{
    private volatile static SingletonLazy instance = null;
    private static Object locker = new Object();
    public static SingletonLazy getInstance(){
        if(instance == null){
            synchronized (locker){
                if(instance == null){
                    instance = new SingletonLazy();
                }
            }
        }
        return instance;
    }
    private SingletonLazy() {};
}

public class ThreadDemo23 {
    public static void main(String[] args) {
        SingletonLazy instance1 = SingletonLazy.getInstance();
        SingletonLazy instance2 = SingletonLazy.getInstance();

        System.out.println(instance1 == instance2);
    }
}
